<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<!--[if IE 7]><html class="ie7 lt-ie10"><![endif]-->
<!--[if IE 8]><html class="ie8 lt-ie10"><![endif]-->
<!--[if IE 9]><html class="ie9 lt-ie10"><![endif]-->
<!--[if gt IE 9]><!-->
<html>
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>阿猫来了的设置_美丽说</title>
<base href="<%=basePath%>">
<meta name="description"
	content="美丽说, 只做正确流行款. 独家冠名《奔跑吧兄弟》! 平台聚集强大的资深时尚买手团队, 每日推出正确新款, 传授最权威的穿衣经验, 全方位解读搭配技巧, 打造当季最前沿的正确流行款!" />
<meta name="keywords" content="美丽说,higo,衣服,鞋子,包包,配饰,家居,美妆,搭配,团购,美丽说higo" />
<link rel="dns-prefetch" href="http://s.meilishuo.net/">
<link rel="dns-prefetch" href="http://i.meilishuo.net/">
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />
<link rel="stylesheet" type="text/css"
	href="pc/css/base.css?1607171726.25" />
<link rel="icon"
	href="pic/_o/75/6e/2f6871f198c0bd7615ffbf9a2f5f_49_48.c5.png"
	type="image/x-icon" />
<link rel="stylesheet" type="text/css"
	href="pc/css/page/account/common.css?1607171726.25" />
<link rel="stylesheet" type="text/css"
	href="pc/css/page/account/setAvatar.css?1607171726.25" />
<script src="js/jquery.min.js" type="text/javascript" ></script>
<script src="admin/assets/layer/layer.js" type="text/javascript" ></script>
<script type="text/javascript">
	window.onload=function(){
		var img=document.getElementById('upimage');
		var file=document.getElementById('filepath');
		file.addEventListener('change',function(){
			var files=this.files[0];
			if(window.FileReader){
				var reader=new FileReader();
				reader.readAsDataURL(files);
				reader.onload=function(e){
					img.setAttribute('src',e.target.result);
				};
			};
		});
	};
	function updUserPhoto(){
		$.ajax({
            cache: false,
            type: "POST",
            processData: false,
			contentType: false,
            url:'/users/updUserPhoto',
            data:new FormData($('#setAvatar')[0]),// 你的formid
            async: false,
            error: function(data) {
                alert("Connection error");
            },
            success: function(data) {
            	if(data==0){
            		layer.msg('修改成功！',{icon:1,time:1500});
            		setTimeout(function(){//两秒后跳转  
            			location.reload();
 	                },1500);
            		
            	}else if(data==-1){
            		layer.msg('修改失败！',{icon:2,time:1500});
            	}else if(data==-2){
            		layer.msg('暂不支持该类型文件！',{icon:2,time:1500});
            	}
            } 
        });
	}
</script>
</head>
<body>
	<jsp:include page="common/header.jsp"></jsp:include>
	<div class="settings">
		<jsp:include page="common/userleft.jsp"></jsp:include>
		<div class="settings_box">
			<strong class="settings_title">个人头像</strong>
			<fieldset>
				<div class="setAvatar">
					<form id="setAvatar" enctype="multipart/form-data">
						<input type="hidden" name="userid" value="${user.userid }"/>
						<div>
							<div class="img_submit">
								<span>选择上传的图片</span> <input id="filepath" type="file" name="file"
									class="img_submit_in" id="img_submit" />
							</div>
							<input type="submit" style="display: none;" id="uploadBtn">
							<iframe id="get_upload_file" name="upload_file" class="none_f"
								frameborder="0"> </iframe>
						</div>
						<p>建议使用正方形的图片，支持JPG、GIF、JPEG、PNG格式，8M以内</p>
						<img src="filecontent/userimg/${user.userphoto }"
							id="upimage" class="original" />
						<div class="clear_both"></div>
					</form>
					<input type="button" onclick="updUserPhoto();" name="save_thumbnail" data-uname="阿猫来了"
						value="确 认" id="set_submit" class="ext_submit" /> <span
						class="submit_error"></span>
				</div>
			</fieldset>
		</div>
	</div>
</body>
</html>